package com.gpj.learn.springcloud.api;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;


@RequestMapping("/server")
@FeignClient(//contextId = "server-main",
		value = "common-server-main", fallback = CommonServer.CommonServerFallback.class)
public interface CommonServer {
	@GetMapping("/info/{id}")
	String info(@PathVariable Integer id);

	@PostMapping("/receive")
	void receive(@RequestParam(required = false) String message);

	@Slf4j
	@Component
	class CommonServerFallback implements CommonServer {
		@Override
		public String info(Integer id) {
			log.warn("feign调用[main]服务的[info]接口失败!");
			return null;
		}

		@Override
		public void receive(String message) {
			log.warn("feign调用[main]服务的[receive]接口失败!");
		}
	}
}
